package com.chen.mapper;

import com.chen.popj.entity.ProblemSubmit;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.ArrayList;


@Mapper
public interface ProblemSubmitMapper {

    /**
     * 根据提交id查询对应的题目信息
     *
     * @param problemSubmitId
     * @return
     */
    @Select("select * from problem_submit where id = #{problemSubmitId}")
    ProblemSubmit getById(long problemSubmitId);

    /**
     * 根据提交id修改提交信息
     *
     * @param problemSubmit
     */
    void updateById(ProblemSubmit problemSubmit);

    /**
     * 根据用户id获取用户个人做题记录
     *
     * @param userId
     * @return
     */
    @Select("select * from problem_submit where user_id=#{userId} and  contest_code_id is null order by submit_time desc")
    ArrayList<ProblemSubmit> querySubmitRecordByUserId(Integer userId);

    /**
     * 根据题目id删除用户题目提交记录
     * @param ids
     */
    void delete(ArrayList<Integer> ids);
}
